<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="店铺账号" prop="storeUserName">
        <el-input v-model="queryParams.storeUserName" placeholder="请输入店铺账号" clearable
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="companyBurshList" border stripe
              @selection-change="handleSelectionChange">
      <el-table-column label="店铺账号" align="center" prop="storeUserName"></el-table-column>
      <el-table-column label="店铺名称" align="center" prop="storeName"></el-table-column>
      <el-table-column label="实际利润" align="center" prop="realProfit"/>
      <el-table-column label="刷单利润" align="center" prop="evaProfit"/>
      <el-table-column label="操作" width="120" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="goOnlineProduct(scope.row)">测评</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
  </div>
</template>

<script>
import {getSelfOperationEvaluation} from "@/api/evaluation/companyBurch";

export default {
  dicts: ['county_code'],
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      companyBurshList: [],//刷单列表
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        storeUserName: undefined,
      },
      // 表单参数
      form: {expenseType: "测评费用",},
      storeList: [],// 卖家列表
      userList: [],// 卖家列表
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询测评订单列表 */
    getList() {
      this.loading = true;
      getSelfOperationEvaluation(this.queryParams).then(res => {
        this.companyBurshList = res.rows
        this.total = res.total
        this.loading = false;
      });
    },
    // 跳转在线商品列表
    goOnlineProduct(row) {
      // this.$router.push({path: "/cost-flow"})
      this.$router.push({
        path: "/sellerStore/sellerStoreProduct",
        query: {type: '1', storeId: row.storeId}
      })
      // this.$router.push({path: "/sellerStoreProduct"})
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        flowType: undefined,
        expenseType: "测评费用",
        payType: undefined,
        userId: undefined,
        money: undefined,
        orderNo: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增测评金额";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          this.form.expenseType = 14
          updateEvaluationAmount(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          }).finally(() => {
            this.buttonLoading = false;
          });
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('seller/sellerStoreAccountLog/export', {
        ...this.queryParams
      }, `sellerStoreAccountLog_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
